<!DOCTYPE html>
<html  lang="zh-CN" >
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=5, viewport-fit=cover">
    <title>ES问题汇总 | 学为我用</title>
    <meta name="description" content="1 ES推送线程如果太多，会出现：es_rejected_execution_exception1rejected execution of org.elasticsearch.transport.TransportService$7@14cee48b onEsThreadPoolExecutor[bulk, queue capacity &#x3D; 50,org.elasticsearch.common">
<meta property="og:type" content="article">
<meta property="og:title" content="ES问题汇总">
<meta property="og:url" content="https://123zhangzhenbin.gitee.io/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/index.html">
<meta property="og:site_name" content="学为我用">
<meta property="og:description" content="1 ES推送线程如果太多，会出现：es_rejected_execution_exception1rejected execution of org.elasticsearch.transport.TransportService$7@14cee48b onEsThreadPoolExecutor[bulk, queue capacity &#x3D; 50,org.elasticsearch.common">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://123zhangzhenbin.gitee.io/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/s1.png">
<meta property="og:image" content="https://123zhangzhenbin.gitee.io/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/s2.png">
<meta property="article:published_time" content="2020-10-12T03:53:33.000Z">
<meta property="article:modified_time" content="2020-10-12T07:32:43.874Z">
<meta property="article:author" content="章瑱彬">
<meta property="article:tag" content="大数据">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://123zhangzhenbin.gitee.io/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/s1.png">

    
    <link rel="icon" href="/zzbomb/images/favicon_128.ico" type="image/x-icon">

    
<link rel="stylesheet" href="/zzbomb/css/common.min.css">



    
    
    
    
        <link href="//cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/css/lightgallery.min.css" rel="stylesheet">
    
    
    
<link rel="stylesheet" href="/zzbomb/css/iconfont.min.css">

    
<meta name="generator" content="Hexo 4.2.1"></head>

    <body>
        <header class="header header-fixture">
    <div class="profile-search-wrap flex sm:block">
        
        
        <div class="profile sm:text-center md:px-1 lg:px-3 sm:pb-4 sm:pt-6">
            <a id="avatar" role="link" href="https://gitee.com/123zhangzhenbin" class="inline-block lg:w-16 lg:h-16 w-8 h-8 m-2" target="_blank" rel="noopener" rel="noreferrer" >
                <img src="/zzbomb/images/g.jpg" class="rounded-full" alt="avatar">
            </a>
            <h2 id="name" class="hidden lg:block">ZZB</h2>
            <h3 id="title" class="hidden xl:block">Java，大数据，人工智能，区块链</h3>
            
            <small id="location" class="hidden lg:block">
                <i class="iconfont icon-map-icon"></i>
                DongGuan, China
            </small>
            
        </div>
        
        
<div class="search flex-1 flex lg:inline-block sm:hidden lg:px-4 lg:mt-2 lg:mb-4 lg:w-full">
    <form id="search-form" class="my-auto flex-1 lg:border lg:border-solid lg:border-gray-200">
        <div class="input-group table bg-gray-100 lg:bg-white w-full">
            <input id="search-input" type="text" placeholder="搜索" class="inline-block w-full bg-gray-100 lg:bg-white">
            <span class="table-cell">
                <button name="search tigger button" disabled>
                    <i class="iconfont icon-search m-2"></i>
                </button>
            </span>
        </div>
    </form>
        
<script id="search-teamplate" type="text/html" data-path="/zzbomb/content.json">
    <div>
        <div class="search-header bg-gray-400">
            <input id="actual-search-input" model="keyword" ref="input" class="inline-block w-full h-10 px-2 py-1" placeholder="搜索" type="text">
        </div>
        <div class="search-result bg-gray-200">
            {{#each searchPosts}}
            <a href="/{{ path }}" class="result-item block px-2 pb-3 mb-1 pt-1 hover:bg-indigo-100">
                <i class="iconfont icon-file"></i>
                <h1 class="result-title inline font-medium text-lg">{{ title }}</h1>
                <p class="result-content text-gray-600 text-sm">{{{ text }}}</p>
            </a>
            {{/each}}
        </div>
    </div>
</script>

</div>


        <button name="menu toogle button" id="menu-toggle-btn" class="block sm:hidden p-3" role="button" aria-expanded="false">
            <i class="iconfont icon-hamburger"></i>
        </button>
    </div>
    <nav id="menu-nav" class="hidden sm:flex flex-col">
        
        
            <div class="menu-item menu-home" role="menuitem">
                <a href="/zzbomb/.">
                    <i class="iconfont icon-home" aria-hidden="true"></i>
                    <span class="menu-title">首页</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-archives" role="menuitem">
                <a href="/zzbomb/archives">
                    <i class="iconfont icon-archive" aria-hidden="true"></i>
                    <span class="menu-title">归档</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-categories" role="menuitem">
                <a href="/zzbomb/categories">
                    <i class="iconfont icon-folder" aria-hidden="true"></i>
                    <span class="menu-title">分类</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-tags" role="menuitem">
                <a href="/zzbomb/tags">
                    <i class="iconfont icon-tag" aria-hidden="true"></i>
                    <span class="menu-title">标签</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-repository" role="menuitem">
                <a href="/zzbomb/repository">
                    <i class="iconfont icon-project" aria-hidden="true"></i>
                    <span class="menu-title">项目</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-links" role="menuitem">
                <a href="/zzbomb/links">
                    <i class="iconfont icon-friend" aria-hidden="true"></i>
                    <span class="menu-title">友链</span>
                </a>
            </div>
        
        
            <div class="menu-item menu-about" role="menuitem">
                <a href="/zzbomb/about">
                    <i class="iconfont icon-cup" aria-hidden="true"></i>
                    <span class="menu-title">关于</span>
                </a>
            </div>
        
        
<div class="social-links flex sm:flex-col lg:hidden mt-5">
    
        <span class="social-item text-center">
            <a href="https://gitee.com/123zhangzhenbin" target="_blank" rel="noopener">
                <i class="iconfont social-icon icon-github"></i>
                <span class="menu-title hidden lg:inline">menu.github</span>
            </a>
        </span>
    
</div>


    </nav>
</header>

        <section class="main-section">
            
    <main class="flex-1 px-4 py-12 md:px-5 lg:px-8 lg:py-4 relative min-h-screen">
    

    <article class="content article article-archives article-type-list" itemscope="">
        <header class="article-header">
            
    
        <h1 class="article-title text-lg" itemprop="name">
            ES问题汇总
        </h1>
    



            <p class="article-meta mb-3 text-xs">
                <span class="article-date">
    <i class="iconfont icon-calendar-check"></i>
	<a href="/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/" class="article-date">
	  <time datetime="2020-10-12T03:53:33.000Z" itemprop="datePublished">10月 12</time>
	</a>
</span>

                

                
    <span class="article-tags">
    <i class="iconfont icon-tag"></i>
    <a class="article-tag-link" href="/zzbomb/tags/%E5%A4%A7%E6%95%B0%E6%8D%AE/" rel="tag">大数据</a>
  </span>


                <span class="_partial/post-comment"><i class="icon icon-comment"></i>
                    <a href="/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/#comments" class="article-comment-link">
                        评论
                    </a>
                </span>
                

            </p>
        </header>
        <div class="marked-body article-body">
            <h2 id="1-ES推送线程如果太多，会出现：es-rejected-execution-exception"><a href="#1-ES推送线程如果太多，会出现：es-rejected-execution-exception" class="headerlink" title="1 ES推送线程如果太多，会出现：es_rejected_execution_exception"></a>1 ES推送线程如果太多，会出现：es_rejected_execution_exception</h2><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs routeros">rejected execution of org.elasticsearch.transport.TransportService<span class="hljs-variable">$7</span>@14cee48b onEsThreadPoolExecutor[bulk,<span class="hljs-built_in"> queue </span>capacity = 50,org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@3ce49360[Running,<span class="hljs-built_in"> pool </span>size = 32, activethreads = 32, queued tasks = 51, completed tasks = 232456918]]<br></code></pre></td></tr></table></figure>

<p>原始异常信息</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs js">&#123;<span class="hljs-string">"index"</span>: <span class="hljs-string">"funddetail-2017-09"</span>,<span class="hljs-string">"type"</span>: <span class="hljs-string">"funddetail"</span>,<span class="hljs-string">"id"</span>: <span class="hljs-string">"AWT2a3Q_u4b-keHzFNoy"</span>,<span class="hljs-string">"cause"</span>: &#123;<span class="hljs-string">"type"</span>: <span class="hljs-string">"es_rejected_execution_exception"</span>,<span class="hljs-string">"reason"</span>: <span class="hljs-string">"rejected execution oforg.elasticsearch.transport.TransportService$7@22f87878 onEsThreadPoolExecutor[bulk, queue capacity = 50,org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@36729cd[Running, pool size = 16, active threads = 16, queued tasks = 50, completedtasks = 917054]]"</span>&#125;,<span class="hljs-string">"status"</span>: <span class="hljs-number">429</span>&#125;<br></code></pre></td></tr></table></figure>
<h3 id="原因探究"><a href="#原因探究" class="headerlink" title="原因探究"></a>原因探究</h3><p>Elasticsearch 在内部维护了线程池。 这些线程池相互协作完成任务，有必要的话相互间还会传递任务。</p>
<p>请求</p>
<figure class="highlight awk"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs awk">GET _nodes<span class="hljs-regexp">/stats/</span>thread_pool<br>GET _cat<span class="hljs-regexp">/thread_pool/</span>bulk?v<br><br><span class="hljs-regexp">//</span>返回<br><br><span class="hljs-string">"thread_pool"</span>: &#123;<span class="hljs-string">"bulk"</span>: &#123;<span class="hljs-string">"threads"</span>: <span class="hljs-number">16</span>,<span class="hljs-string">"queue"</span>: <span class="hljs-number">0</span>,<span class="hljs-string">"active"</span>: <span class="hljs-number">0</span>,<span class="hljs-string">"rejected"</span>: <span class="hljs-number">0</span>,<span class="hljs-string">"largest"</span>: <span class="hljs-number">16</span>,<span class="hljs-string">"completed"</span>: <span class="hljs-number">1480561</span>&#125;,...<br></code></pre></td></tr></table></figure>
<p>请求查看线程池信息：每个线程池会列出已配置的线程数量（ threads ），当前在处理任务的线程数量（ active ），以及在队列中等待处理的任务单元数量（ queue ）如果队列中任务单元数达到了极限，新的任务单元会开始被拒绝，你会在 rejected 统计值上看到它反映出来。这通常是你的集群在某些资源上碰到瓶颈的信号。</p>
<p>因为队列满意味着你的节点或集群在用最高速度运行，但依然跟不上数据的蜂拥而入。需要注意的是：增加队列大小并不能增加性能，它只是隐藏了问题。当你的集群只能每秒钟处理 10000 个文档的时候，无论队列是 100 还是10000000 都没关系——你的集群还是只能每秒处理 10000 个文档。</p>
<h3 id="解决方案："><a href="#解决方案：" class="headerlink" title="解决方案："></a>解决方案：</h3><p>限流或重新推送，并在推送失败超过10次时报错</p>
<h2 id="2-一次性查询不能超过1000个shard"><a href="#2-一次性查询不能超过1000个shard" class="headerlink" title="2 一次性查询不能超过1000个shard"></a>2 一次性查询不能超过1000个shard</h2><p><img src="/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/s1.png" alt="s1"><br><img src="/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/s2.png" alt="s2"></p>
<p>一次性查询不能超过1000个shard，现在是16个shard，如果按日120天，16 * 120 = 1920 &gt; 1000</p>
<h3 id="解决方案：-1"><a href="#解决方案：-1" class="headerlink" title="解决方案："></a>解决方案：</h3><p>合并索引，减少拆分索引，减少分片。也可以增加查寻shard数量，不过一般生产上不建议这么做，会极大降低性能。</p>
<h2 id="3-ES默认结果Window查询上限为10000"><a href="#3-ES默认结果Window查询上限为10000" class="headerlink" title="3 ES默认结果Window查询上限为10000"></a>3 ES默认结果Window查询上限为10000</h2><h3 id="解决方案：-2"><a href="#解决方案：-2" class="headerlink" title="解决方案："></a>解决方案：</h3><ol>
<li>提高查询上限。不建议<figure class="highlight protobuf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs protobuf">PUT we_funddetail_tuomin/_settings?preserve_existing=<span class="hljs-literal">true</span>&#123;<span class="hljs-string">"max_result_window"</span> : <span class="hljs-string">"2000000000"</span>&#125;<br></code></pre></td></tr></table></figure></li>
<li>滑动分页。<br>scroll分页</li>
</ol>
<h2 id="4-ES-客户端数量过多"><a href="#4-ES-客户端数量过多" class="headerlink" title="4 ES 客户端数量过多"></a>4 ES 客户端数量过多</h2><p>如果每次ES请求都创建一个client进行连接，很快就会达到连接数上限</p>
<p>原始异常信息</p>
<figure class="highlight reasonml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs reasonml">Exception <span class="hljs-keyword">in</span> thread <span class="hljs-string">"Thread-0"</span> org.jboss.netty.channel.ChannelException:Failed <span class="hljs-keyword">to</span> create a selector.atorg.jboss.netty.channel.socket.nio.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractNioSelector</span>.</span></span><span class="hljs-keyword">open</span><span class="hljs-constructor">Selector(AbstractNioSelector.<span class="hljs-params">java</span>:362)</span>atorg.jboss.netty.channel.socket.nio.AbstractNioSelector.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractNioSelector</span>.</span></span>java:<span class="hljs-number">100</span>)atorg.jboss.netty.channel.socket.nio.AbstractNioWorker.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractNioWorker</span>.</span></span>java:<span class="hljs-number">52</span>)at org.jboss.netty.channel.socket.nio.NioWorker.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">NioWorker</span>.</span></span>java:<span class="hljs-number">45</span>)atorg.jboss.netty.channel.socket.nio.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">NioWorkerPool</span>.</span></span><span class="hljs-keyword">new</span><span class="hljs-constructor">Worker(NioWorkerPool.<span class="hljs-params">java</span>:44)</span>atorg.jboss.netty.channel.socket.nio.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">NioWorkerPool</span>.</span></span><span class="hljs-keyword">new</span><span class="hljs-constructor">Worker(NioWorkerPool.<span class="hljs-params">java</span>:28)</span>atorg.jboss.netty.channel.socket.nio.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractNioWorkerPool</span>.</span></span>init(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractNioWorkerPool</span>.</span></span>java:<span class="hljs-number">80</span>)atorg.jboss.netty.channel.socket.nio.NioWorkerPool.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">NioWorkerPool</span>.</span></span>java:<span class="hljs-number">39</span>)atorg.jboss.netty.channel.socket.nio.NioWorkerPool.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">NioWorkerPool</span>.</span></span>java:<span class="hljs-number">33</span>)atorg.elasticsearch.transport.netty3.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Netty3Transport</span>.</span></span>create<span class="hljs-constructor">ClientBootstrap(Netty3Transport.<span class="hljs-params">java</span>:204)</span>atorg.elasticsearch.transport.netty3.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Netty3Transport</span>.</span></span><span class="hljs-keyword">do</span><span class="hljs-constructor">Start(Netty3Transport.<span class="hljs-params">java</span>:170)</span>atorg.elasticsearch.xpack.security.transport.netty3.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SecurityNetty3Transport</span>.</span></span><span class="hljs-keyword">do</span><span class="hljs-constructor">Start(SecurityNetty3Transport.<span class="hljs-params">java</span>:75)</span>atorg.elasticsearch.common.component.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractLifecycleComponent</span>.</span></span>start(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractLifecycleComponent</span>.</span></span>java:<span class="hljs-number">69</span>)atorg.elasticsearch.transport.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">TransportService</span>.</span></span><span class="hljs-keyword">do</span><span class="hljs-constructor">Start(TransportService.<span class="hljs-params">java</span>:202)</span>atorg.elasticsearch.common.component.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractLifecycleComponent</span>.</span></span>start(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractLifecycleComponent</span>.</span></span>java:<span class="hljs-number">69</span>)atorg.elasticsearch.client.transport.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">TransportClient</span>.</span></span>build<span class="hljs-constructor">Template(TransportClient.<span class="hljs-params">java</span>:198)</span>atorg.elasticsearch.client.transport.TransportClient.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">TransportClient</span>.</span></span>java:<span class="hljs-number">258</span>)atorg.elasticsearch.transport.client.PreBuiltTransportClient.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PreBuiltTransportClient</span>.</span></span>java:<span class="hljs-number">125</span>)atorg.elasticsearch.xpack.client.PreBuiltXPackTransportClient.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PreBuiltXPackTransportClient</span>.</span></span>java:<span class="hljs-number">55</span>)atorg.elasticsearch.xpack.client.PreBuiltXPackTransportClient.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PreBuiltXPackTransportClient</span>.</span></span>java:<span class="hljs-number">50</span>)atorg.elasticsearch.xpack.client.PreBuiltXPackTransportClient.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PreBuiltXPackTransportClient</span>.</span></span>java:<span class="hljs-number">46</span>)atcom.tuandai.index.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">FundetailIndexTests</span>.</span></span>get<span class="hljs-constructor">EsClient(FundetailIndexTests.<span class="hljs-params">java</span>:177)</span>atcom.tuandai.index.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">FundetailIndexTests</span>.</span></span>bulk<span class="hljs-constructor">IndexRequest(FundetailIndexTests.<span class="hljs-params">java</span>:109)</span>at com.tuandai.index.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">FundetailIndexTests</span>.</span></span>run(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">FundetailIndexTests</span>.</span></span>java:<span class="hljs-number">63</span>)at java.lang.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Thread</span>.</span></span>run(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Thread</span>.</span></span>java:<span class="hljs-number">748</span>)Caused by: java.io.IOException: Unable <span class="hljs-keyword">to</span> establish loopback connectionat sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl$Initializer</span>.</span></span>run(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl</span>.</span></span>java:<span class="hljs-number">94</span>)at sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl$Initializer</span>.</span></span>run(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl</span>.</span></span>java:<span class="hljs-number">61</span>)at java.security.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AccessController</span>.</span></span><span class="hljs-keyword">do</span><span class="hljs-constructor">Privileged(Native Method)</span>at sun.nio.ch.PipeImpl.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl</span>.</span></span>java:<span class="hljs-number">171</span>)at sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SelectorProviderImpl</span>.</span></span><span class="hljs-keyword">open</span><span class="hljs-constructor">Pipe(SelectorProviderImpl.<span class="hljs-params">java</span>:50)</span>at java.nio.channels.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Pipe</span>.</span></span><span class="hljs-keyword">open</span>(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Pipe</span>.</span></span>java:<span class="hljs-number">155</span>)at sun.nio.ch.WindowsSelectorImpl.&lt;init&gt;(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">WindowsSelectorImpl</span>.</span></span>java:<span class="hljs-number">127</span>)atsun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">WindowsSelectorProvider</span>.</span></span><span class="hljs-keyword">open</span><span class="hljs-constructor">Selector(WindowsSelectorProvider.<span class="hljs-params">java</span>:44)</span>at java.nio.channels.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Selector</span>.</span></span><span class="hljs-keyword">open</span>(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Selector</span>.</span></span>java:<span class="hljs-number">227</span>)atorg.jboss.netty.channel.socket.nio.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SelectorUtil</span>.</span></span><span class="hljs-keyword">open</span>(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SelectorUtil</span>.</span></span>java:<span class="hljs-number">63</span>)atorg.jboss.netty.channel.socket.nio.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AbstractNioSelector</span>.</span></span><span class="hljs-keyword">open</span><span class="hljs-constructor">Selector(AbstractNioSelector.<span class="hljs-params">java</span>:360)</span>... <span class="hljs-number">24</span> moreCaused by: java.net.SocketException: No buffer space available (maximumconnections reached?): connectat sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Net</span>.</span></span>connect0(Native Method)at sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Net</span>.</span></span>connect(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Net</span>.</span></span>java:<span class="hljs-number">454</span>)at sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Net</span>.</span></span>connect(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">Net</span>.</span></span>java:<span class="hljs-number">446</span>)at sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SocketChannelImpl</span>.</span></span>connect(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SocketChannelImpl</span>.</span></span>java:<span class="hljs-number">648</span>)at java.nio.channels.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SocketChannel</span>.</span></span><span class="hljs-keyword">open</span>(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">SocketChannel</span>.</span></span>java:<span class="hljs-number">189</span>)atsun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl$Initializer$LoopbackConnector</span>.</span></span>run(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl</span>.</span></span>java:<span class="hljs-number">127</span>)at sun.nio.ch.<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl$Initializer</span>.</span></span>run(<span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">PipeImpl</span>.</span></span>java:<span class="hljs-number">76</span>)... <span class="hljs-number">34</span> more<br></code></pre></td></tr></table></figure>

<h3 id="解决方案：-3"><a href="#解决方案：-3" class="headerlink" title="解决方案："></a>解决方案：</h3><p>复用连接，建立连接池</p>

        </div>
        
<blockquote class="copyright">
    <p><strong>本文链接 : </strong><a class="permalink" href="https://123zhangzhenbin.gitee.io/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/">https://123zhangzhenbin.gitee.io/zzbomb/2020/10/12/202010121150-es-knowledge-inheritance/</a></p>
    <p><strong>This article is available under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="noopener noreferrer">Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)</a> License</strong></p>
</blockquote>


    </article>
    
    <section id="comments">
        
    </section>


    

</main>


<aside style="" id="sidebar" class="aside aside-fixture">
    <div class="toc-sidebar">
        <nav id="toc" class="article-toc">
            <h3 class="toc-title">文章目录</h3>
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-ES推送线程如果太多，会出现：es-rejected-execution-exception"><span class="toc-number">1.</span> <span class="toc-text">1 ES推送线程如果太多，会出现：es_rejected_execution_exception</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#原因探究"><span class="toc-number">1.1.</span> <span class="toc-text">原因探究</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#解决方案："><span class="toc-number">1.2.</span> <span class="toc-text">解决方案：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-一次性查询不能超过1000个shard"><span class="toc-number">2.</span> <span class="toc-text">2 一次性查询不能超过1000个shard</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#解决方案：-1"><span class="toc-number">2.1.</span> <span class="toc-text">解决方案：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-ES默认结果Window查询上限为10000"><span class="toc-number">3.</span> <span class="toc-text">3 ES默认结果Window查询上限为10000</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#解决方案：-2"><span class="toc-number">3.1.</span> <span class="toc-text">解决方案：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-ES-客户端数量过多"><span class="toc-number">4.</span> <span class="toc-text">4 ES 客户端数量过多</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#解决方案：-3"><span class="toc-number">4.1.</span> <span class="toc-text">解决方案：</span></a></li></ol></li></ol>
        </nav>
    </div>
</aside>





        </section>
        <footer class="hidden lg:block fixed bottom-0 left-0 sm:w-1/12 lg:w-1/6 bg-gray-100 z-40">
    
    <div class="footer-social-links">
        
            <a href="https://gitee.com/123zhangzhenbin" target="_blank" rel="noopener">
                <i class="iconfont icon-github"></i>
            </a>
        
    </div>
    
    <p style="display: block;text-align: center;font-size: 13px;"><a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备16013026号</a></p>
    
        <p class="footer-custom"><a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备16013026号</a></p>
        <p class="theme-brand">Theme by <a href="https://github.com/fengkx/hexo-theme-purer" target="_blank" rel="nofollow noopener noreferrer noopener">hexo-theme-purer</a></p>

    
</footer>

        <div id="mask" class="hidden mask fixed inset-0 bg-gray-900 opacity-75 z-40"></div>
        <div id="search-view-container" class="hidden shadow-xl"></div>
        
<script src="/zzbomb/js/dom-event.min.js"></script>

<script src="//cdn.jsdelivr.net/npm/yox@1.0.0-alpha.121/dist/standard/prod/yox.min.js"></script>


<script src="/zzbomb/js/search.min.js"></script>



    <script src="//cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/js/lightgallery.min.js"></script>
    
<script src="/zzbomb/js/light-gallery.min.js"></script>





    </body>
</html>
